1. Field of the Invention
The present invention relates to a barrel shifter which can be easily realized in the form of an integrated circuit.
In arithmetic operations and logic operations, use is made of a barrel shifter to shift a desired number of bits in a desired direction in a machine cycle. An arithmetic operation shift is used, for example, in a digital signal processor (DSP) and, for example, will perform a right-direction shift of one bit, two bits, three bits, etc. of a bit train to achieve at one time a division operation of 1/2, 1/4, 1/8, and so on. Conversely, it will perform a left-direction shift of one bit, two bits, three bits, etc. to achieve at one time a multiplication operation of X2, X4, X8, etc. In this case, the barrel shifter is mounted near the arithmetic and logic unit (ALU) in the DSP and cooperates with the ALU.
On the other hand, the logic operation shift is used for processing data in a central processing unit (CPU). For example, when 16-bit data is received and the requisite 4-bit portion thereof is at the lower bit side, if it is desired to move this 4-bit portion to the upper bit side for loading in the CPU memory, this shift is used to shift the 4-bit portion at one time.
The hardware structure of this barrel shifter becomes larger in accordance with the increase of the operation accuracy, and thus use of an integrated circuit for the same is difficult. Therefore, there is a demand for a structure which can be realized on a relatively small circuit scale, even when there are a large number of data bits, and which facilitates use of an integrated circuit.
2. Description of the Related Art
Shift registers are in general use as circuits for shifting data, but only enable 1-bit shifts with each clock. Therefore, when shifting a plurality of bits, a plurality of clocks are required. Therefore, a problem arises in that the shift operation takes a long time when a large number of bits must be shifted. Accordingly, a barrel shifter is used for shifting a plurality of bits in one machine cycle.
Two types of conventional barrel shifter are known, both described later. In the first type, an increase in the number of bits of data drastically enlarges the circuit size of the barrel shifter and makes the use of an integrated circuit difficult.
In the second type, an increase in the number of bits of data complicates the shift control.